
package kr.hkit.powerjava.chapter23;

import java.awt.Font;
import java.awt.HeadlessException;

import javax.swing.JFrame;
import javax.swing.JLabel;

public class CountDownTest extends JFrame {
	private JLabel label;

	class MyThread extends Thread {
		
		public MyThread() {
			this.start();
		}

		@Override
		public void run() {
			for (int i = 10; i > 0; i--) {

				try {
					Thread.sleep(1000); // 1초
				} catch (InterruptedException e) {
					e.printStackTrace();
				}
				label.setText(i + "");
			}
		}
	}

	public CountDownTest() throws HeadlessException {
		setTitle("카운트 다운");								//타이틀
		setSize(300, 200);									//창 사이즈
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);		//종료

		label = new JLabel("Start");						//시작화면
		label.setFont(new Font("Serif", Font.BOLD, 100));	//폰트
		add(label);

		Thread t = new MyThread();
		setVisible(true);
		while(t.isAlive());
		System.exit(0);
	}

	public static void main(String[] args) {
		new CountDownTest();
	}
}
